package com.fdb.efp.nls.service.impl.psd.credit;

import com.fdb.efp.nls.service.domain.psd.PsdTaskReqInfo;
import com.fdb.efp.nls.service.facade.psd.PsdTaskReqInfoService;
import com.fdb.efp.nls.service.vo.psd.PsdTaskReqInfoVO;
import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.efp.nls.service.dao.psd.PsdTaskReqInfoDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

@Service("psdTaskReqInfoService")
public class PsdTaskReqInfoServiceImpl implements PsdTaskReqInfoService,FrameworkService {

    @Autowired
    private PsdTaskReqInfoDAO psdTaskReqInfoDAO;

    @Override
    public Integer insert(PsdTaskReqInfoVO record) {
        return psdTaskReqInfoDAO.insert(beanCopy(record,new PsdTaskReqInfo()));
    }

    @Override
    public Integer insertSelective(PsdTaskReqInfoVO record) {
        return psdTaskReqInfoDAO.insertSelective(beanCopy(record,new PsdTaskReqInfo()));
    }

    @Override
    public Integer updateByPrimaryKey(PsdTaskReqInfoVO record) {
        return psdTaskReqInfoDAO.updateByPrimaryKey(beanCopy(record,new PsdTaskReqInfo()));
    }

    @Override
    public Integer deleteByPrimaryKey(String orderId) {
        return psdTaskReqInfoDAO.deleteByPrimaryKey(orderId);
    }

    @Override
    public PsdTaskReqInfoVO selectByPrimaryKey(String oderId) {
        return beanCopy(psdTaskReqInfoDAO.selectByPrimaryKey(oderId),new PsdTaskReqInfoVO());
    }

    @Override
    public List<PsdTaskReqInfoVO> selectRecordByHandleStatus(Integer status) throws Exception {
        return (List<PsdTaskReqInfoVO>) beansCopy(psdTaskReqInfoDAO.selectRecordByHandleStatus(status),PsdTaskReqInfoVO.class);
    }

    private static Logger logger = LoggerFactory.getLogger(PsdTaskReqInfoServiceImpl.class);

    /**
     * 查询用户权限数据
     */
    @SuppressWarnings("unchecked")
    public List<PsdTaskReqInfoVO> queryAllOwner(PsdTaskReqInfoVO psdTaskReqInfoVo) {

        logger.debug("当前查询本人所属数据信息的参数信息为:");
        List<PsdTaskReqInfoVO> list = null;
        try {
            List<PsdTaskReqInfo> psdTaskReqInfos = psdTaskReqInfoDAO.queryAllOwnerByPage(psdTaskReqInfoVo);
            logger.debug("当前查询本人所属数据信息的结果集数量为:"+ psdTaskReqInfos.size());
            pageSet(psdTaskReqInfos, psdTaskReqInfoVo);
            list = (List<PsdTaskReqInfoVO>) beansCopy(psdTaskReqInfos, PsdTaskReqInfoVO.class);
        } catch (Exception e) {
            logger.error("数据转换出现异常!", e);
        }

        return list;
    }

}